{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "43c6d60f-3ac4-4363-b8db-2fad9c1b7e9b",
   "metadata": {},
   "source": [
    "## 集合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ca5ef457-2bcd-4fe1-8b66-991b3b85ba94",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{10, 20, 30}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "{10, 10, 20, 20, 30, 30}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "aaf24747-469a-42ea-9fea-0deb7bb05886",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "set()"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "042153be-a777-44e0-ba42-f6776f3758b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type({})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b85b6f38-4c9f-45d6-854c-e8b1a3cd1055",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e15e0cb5-6779-4d32-a3df-b02e2ae5811f",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{20}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = {10, 20}\n",
    "b = {20, 30}\n",
    "a & b # 交集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0afd9203-9525-40d0-a20c-f54485a0b679",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{10, 20, 30}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a | b # 并集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "24d7f35a-844e-4237-b6f9-68f0be2d140c",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{10}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a - b # 差集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4389dc9d-1114-4df7-83aa-7887ebe06d84",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{30}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b - a "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7b8ec176-b7e5-436e-b7e5-9c5aacfc4276",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{10, 30}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a ^ b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "22709730-633a-4934-ab36-434f70491553",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = {10, 20}\n",
    "20 in a # 是否属于该集合"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
